<?php
/***************************************************************************
 * 
 * Copyright (c) 2010 , Inc. All Rights Reserved
 * $Id$:ActionController.php,2010/05/10 11:41:44 
 * 
 **************************************************************************/
 
 
 
/**
 * @file ActionController.php
 * @author huqingping
 * @date 2010/05/10 11:41:44
 * @version 1.0 
 * @brief 
 *  
 **/

final class ActionController extends PageController 
{

	function testFatal()
	{
		$a++;
	}

	function testException()
	{
		$code = $this->get('code');
		throw new Exception($code);
	}

	function testSkipFatal()
	{
		@include "not_exist";
	}

	function index()
	{

	}

	function testErr2Json()
	{
		throw new Exception('hapn.err2json');
	}

	function testInput()
	{
		foreach($this->request->inputs as $key=>$value) {
			$this->set($key,$value);
		}

		foreach($this->request->cookies as $key=>$cookie)
		{
			$this->response->setCookie($key,$cookie);
		}

		foreach($this->request->serverEnvs as $key=>$header)
		{
			if (strncmp($key, 'HTTP_', 5) === 0) {
				$this->response->setHeader(substr($key,5).': '.$header);
			}
		}

		$this->set('novalue',$this->get('novalue'));
		$this->set('defaultvalue',$this->get('defaultvalue','default'));

		$this->set('_if',$this->request->if);
		$this->set('_ie',$this->request->ie);
		$this->set('_of',$this->request->of);
		$this->set('_oe',$this->request->oe);
		$this->set('_ip',$this->request->userip);
		$this->set('_cip',$this->request->clientip);
		$this->set('_now',$this->request->now);

	}

	function testRedirectHeader()
	{
		$this->response->setHeader('aaa: bbb');
		$this->response->setCookie('mykey','myname');
		$this->response->redirect('/aa');
	}

	function testEncoding()
	{
		foreach($this->request->inputs as $key=>$value) {
			$this->set($key,$value);
		}
		$this->set('测试','测试');
	}

	function testFormat()
	{
		foreach($this->request->inputs as $key=>$value) {
			$this->set($key,$value);
		}
	}

	function _mustpost()
	{

	}

	function testView()
	{
		foreach($this->request->inputs as $key=>$value) {
			$this->set($key,$value);
		}
		$this->setView('HapN/view');	
	}

	function testAppConf()
	{
		$this->set('HapNconf',Conf::get('HapNconf'));
	}

	function testInputCheck()
	{
		$arr_rules = array(
			'key1' => array(
				'func' => 'TELNO',
			),
			'key2' => array(
				'func' => 'IDNUM',
			),    
		);
		$ret = $this->checkInput($arr_rules);
		$this->set('ret', $ret);
	}

	function testNocacheAndEnd()
	{
		$this->response->setNoCache();
		$this->response->end();
		echo "can't process\n";
	}

	function testLogin()
	{
		throw new Exception('hapn.u_login');
	}

}






/* vim: set ts=4 sw=4 sts=4 tw=100 noet: */
?>
